<?php
declare (strict_types = 1);

namespace util;

/**
 * 
 */
class Tree
{
    /**
     * 无限极树
     */
    public static function arrayToTree($arr, $pid = 0, $options =[]) {
        $roots = [];
        foreach($arr as $item) {
            if($item['pid'] == $pid) {
                $item['children'] = self::arrayToTree($arr, $item['id'], $options);
                $roots[] = $item;
            }
        }
        return $roots;
    }
}